package indi.zjh.dp.verify;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class RegularRule implements Rule{
	public static final String IP_PATTERN = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
	protected String pattern;
	
	public RegularRule(String pattern)
	{
		this.pattern = pattern;
	}
	public boolean test(String input)
	{
		Pattern pattern = Pattern.compile(this.pattern);
		Matcher matcher = pattern.matcher(input);
		return matcher.find();
	}
	@Override
	public String desc() {
		// TODO Auto-generated method stub
		return "输入字符串不满足正则表达式"+this.pattern;
	}
}
